{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import geopandas as gpd\n",
    "import seaborn as sns   \n",
    "import plotting\n",
    "hspts = plotting.get_hotspot_list()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This notebook provides statistics from Table 1 and Supplementary Table 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "gdf = gpd.read_file(\"outputs/d2-events-2d-230929_SVI_shapefile.geojson\")\n",
    "gdf = gdf[['FIPS', 'ST_ABBR', 'E_TOTPOP']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "gdf = gdf[gdf['ST_ABBR'] != 'TX']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18106"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf.FIPS.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "75506421"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf[\"E_TOTPOP\"].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_parquet(\"outputs/d2-events-2d5-230929.parquet\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Get yearly sums of exposure per census tract\n",
    "df = df.reset_index()\n",
    "df = df.groupby(\"GEOID\").resample(\"Y\", on=\"time\").sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.drop(columns=[\"GEOID\"], inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>wfday</th>\n",
       "      <th>heatday</th>\n",
       "      <th>smoke_pm_non_zero</th>\n",
       "      <th>smoke_pm_gt_five</th>\n",
       "      <th>hw</th>\n",
       "      <th>_hws</th>\n",
       "      <th>hs</th>\n",
       "      <th>hws</th>\n",
       "      <th>ws</th>\n",
       "      <th>hs5</th>\n",
       "      <th>...</th>\n",
       "      <th>wfday_2d</th>\n",
       "      <th>_hws_2d</th>\n",
       "      <th>hs_2d</th>\n",
       "      <th>hws_2d</th>\n",
       "      <th>ws_2d</th>\n",
       "      <th>hw_2d</th>\n",
       "      <th>smoke_pm_gt_five_2d</th>\n",
       "      <th>hs_2d_5</th>\n",
       "      <th>ws_2d_5</th>\n",
       "      <th>hws_2d_5</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GEOID</th>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">04001942600</th>\n",
       "      <th>2006-12-31</th>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>54</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007-12-31</th>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "      <td>19</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>28</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>43</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008-12-31</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>24</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>26</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>43</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009-12-31</th>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>22</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-12-31</th>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>18</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>24</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>35</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        wfday  heatday  smoke_pm_non_zero  smoke_pm_gt_five  \\\n",
       "GEOID       time                                                              \n",
       "04001942600 2006-12-31      0        8                 29                 2   \n",
       "            2007-12-31      0       11                 19                 2   \n",
       "            2008-12-31      1        2                 24                 0   \n",
       "            2009-12-31      0        4                 22                 3   \n",
       "            2010-12-31      0        6                 18                 0   \n",
       "\n",
       "                        hw  _hws  hs  hws  ws  hs5  ...  wfday_2d  _hws_2d  \\\n",
       "GEOID       time                                    ...                      \n",
       "04001942600 2006-12-31   0    37   0    0   0    0  ...         0       54   \n",
       "            2007-12-31   0    28   2    0   0    1  ...         0       43   \n",
       "            2008-12-31   0    26   1    0   0    0  ...         2       43   \n",
       "            2009-12-31   0    25   1    0   0    0  ...         0       37   \n",
       "            2010-12-31   0    24   0    0   0    0  ...         0       35   \n",
       "\n",
       "                        hs_2d  hws_2d  ws_2d  hw_2d  smoke_pm_gt_five_2d  \\\n",
       "GEOID       time                                                           \n",
       "04001942600 2006-12-31      4       0      0      0                    3   \n",
       "            2007-12-31      3       0      0      0                    3   \n",
       "            2008-12-31      2       0      0      0                    0   \n",
       "            2009-12-31      2       0      0      0                    5   \n",
       "            2010-12-31      0       0      0      0                    0   \n",
       "\n",
       "                        hs_2d_5  ws_2d_5  hws_2d_5  \n",
       "GEOID       time                                    \n",
       "04001942600 2006-12-31        0        0         0  \n",
       "            2007-12-31        2        0         0  \n",
       "            2008-12-31        0        0         0  \n",
       "            2009-12-31        0        0         0  \n",
       "            2010-12-31        0        0         0  \n",
       "\n",
       "[5 rows x 24 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "hspts = ['wfday', 'heatday', 'smoke_pm_non_zero', 'smoke_pm_gt_five',\n",
    "       'hw', '_hws', 'hs', 'hws', 'ws', 'hs5', 'hws5', 'ws5', 'heatday_2d',\n",
    "       'smoke_pm_non_zero_2d', 'wfday_2d', '_hws_2d', 'hs_2d', 'hws_2d',\n",
    "       'ws_2d', 'hw_2d', 'smoke_pm_gt_five_2d', 'hs_2d_5', 'ws_2d_5',\n",
    "       'hws_2d_5']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_mean_and_std(groupped_df, hspts):\n",
    "    \"\"\"Get mean and standard deviation of a list of hotspots for a groupped dataframe.\"\"\"\n",
    "    mean = groupped_df[hspts].mean()\n",
    "    std = groupped_df[hspts].std()\n",
    "    #geoid_combined = mean.map('{:,.1f}'.format) + \" (\" + std.map('{:,.1f}'.format) + \")\"\n",
    "    geoid_combined = mean.map('{:,.0f}'.format) + \" (\" + std.map('{:,.0f}'.format) + \")\"\n",
    "    return geoid_combined"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tract-day exposure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18106"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf[\"FIPS\"].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Census-tract inclusions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FIPS</th>\n",
       "      <th>E_TOTPOP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ST_ABBR</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>AZ</th>\n",
       "      <td>1765</td>\n",
       "      <td>1765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CA</th>\n",
       "      <td>9095</td>\n",
       "      <td>9095</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CO</th>\n",
       "      <td>1447</td>\n",
       "      <td>1447</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ID</th>\n",
       "      <td>456</td>\n",
       "      <td>456</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MT</th>\n",
       "      <td>319</td>\n",
       "      <td>319</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NM</th>\n",
       "      <td>612</td>\n",
       "      <td>612</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NV</th>\n",
       "      <td>779</td>\n",
       "      <td>779</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>OR</th>\n",
       "      <td>991</td>\n",
       "      <td>991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>UT</th>\n",
       "      <td>716</td>\n",
       "      <td>716</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WA</th>\n",
       "      <td>1766</td>\n",
       "      <td>1766</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>WY</th>\n",
       "      <td>160</td>\n",
       "      <td>160</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         FIPS  E_TOTPOP\n",
       "ST_ABBR                \n",
       "AZ       1765      1765\n",
       "CA       9095      9095\n",
       "CO       1447      1447\n",
       "ID        456       456\n",
       "MT        319       319\n",
       "NM        612       612\n",
       "NV        779       779\n",
       "OR        991       991\n",
       "UT        716       716\n",
       "WA       1766      1766\n",
       "WY        160       160"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf.groupby(\"ST_ABBR\").count()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Census tract numbers from the web:\n",
    "\n",
    "- Arizona 1,765\n",
    "- California      9,129\n",
    "- Colorado        1,447\n",
    "- Idaho   456\n",
    "- Montana 319\n",
    "- Nevada  779\n",
    "- New Mexico      612\n",
    "- Oregon  1,001\n",
    "- Utah    716\n",
    "- Washington      1,784\n",
    "- Wyoming 160"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18168"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1765+9129+1447+456+319+779+612+1001+716+1784+160"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "62"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Difference from our map\n",
    "18168-18106"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18106"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"GEOID\"].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [],
   "source": [
    "# include just FIPS from SVI index data\n",
    "\n",
    "df = df[df['GEOID'].isin(gdf[\"FIPS\"].unique())]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18106"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"GEOID\"].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "geoid_group = df[[\"GEOID\"]+ hspts].groupby([\"GEOID\"]).sum().div(15) # 15 years\n",
    "year_group = df[[\"time\"]+ hspts].groupby([\"time\"]).sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [],
   "source": [
    "res = pd.DataFrame()\n",
    "res[\"avg_exposure_days_per_year\"] = get_mean_and_std(year_group, hspts)\n",
    "res[\"avg_exposure_days_per_ct\"] = get_mean_and_std(geoid_group, hspts)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Person-day exposure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pdf = gdf.merge(df, left_on=\"FIPS\", right_on=\"GEOID\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FIPS</th>\n",
       "      <th>ST_ABBR</th>\n",
       "      <th>E_TOTPOP</th>\n",
       "      <th>level_0</th>\n",
       "      <th>index</th>\n",
       "      <th>GEOID</th>\n",
       "      <th>time</th>\n",
       "      <th>wfday</th>\n",
       "      <th>heatday</th>\n",
       "      <th>smoke_pm_non_zero</th>\n",
       "      <th>...</th>\n",
       "      <th>wfday_2d</th>\n",
       "      <th>_hws_2d</th>\n",
       "      <th>hs_2d</th>\n",
       "      <th>hws_2d</th>\n",
       "      <th>ws_2d</th>\n",
       "      <th>hw_2d</th>\n",
       "      <th>smoke_pm_gt_five_2d</th>\n",
       "      <th>hs_2d_5</th>\n",
       "      <th>ws_2d_5</th>\n",
       "      <th>hws_2d_5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2006-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>13688</td>\n",
       "      <td>49619</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>92394</td>\n",
       "      <td>6844</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5133</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2007-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>18821</td>\n",
       "      <td>32509</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>73573</td>\n",
       "      <td>5133</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5133</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2008-12-31</td>\n",
       "      <td>1711</td>\n",
       "      <td>3422</td>\n",
       "      <td>41064</td>\n",
       "      <td>...</td>\n",
       "      <td>3422</td>\n",
       "      <td>73573</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2009-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>6844</td>\n",
       "      <td>37642</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>63307</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8555</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2010-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>10266</td>\n",
       "      <td>30798</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>59885</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 31 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          FIPS ST_ABBR  E_TOTPOP  level_0  index        GEOID       time  \\\n",
       "0  04001942600      AZ      1711        0      0  04001942600 2006-12-31   \n",
       "1  04001942600      AZ      1711        1      1  04001942600 2007-12-31   \n",
       "2  04001942600      AZ      1711        2      2  04001942600 2008-12-31   \n",
       "3  04001942600      AZ      1711        3      3  04001942600 2009-12-31   \n",
       "4  04001942600      AZ      1711        4      4  04001942600 2010-12-31   \n",
       "\n",
       "   wfday  heatday  smoke_pm_non_zero  ...  wfday_2d  _hws_2d  hs_2d  hws_2d  \\\n",
       "0      0    13688              49619  ...         0    92394   6844       0   \n",
       "1      0    18821              32509  ...         0    73573   5133       0   \n",
       "2   1711     3422              41064  ...      3422    73573   3422       0   \n",
       "3      0     6844              37642  ...         0    63307   3422       0   \n",
       "4      0    10266              30798  ...         0    59885      0       0   \n",
       "\n",
       "   ws_2d  hw_2d  smoke_pm_gt_five_2d  hs_2d_5  ws_2d_5  hws_2d_5  \n",
       "0      0      0                 5133        0        0         0  \n",
       "1      0      0                 5133     3422        0         0  \n",
       "2      0      0                    0        0        0         0  \n",
       "3      0      0                 8555        0        0         0  \n",
       "4      0      0                    0        0        0         0  \n",
       "\n",
       "[5 rows x 31 columns]"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# multiply hspts by E_TOTPOP to get person-day exposure\n",
    "pdf[hspts] = pdf[hspts].mul(pdf[\"E_TOTPOP\"], axis=0)\n",
    "pdf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18106"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pdf[\"FIPS\"].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'pdf' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[15], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m geoid_group \u001b[38;5;241m=\u001b[39m \u001b[43mpdf\u001b[49m[[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGEOID\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m+\u001b[39m hspts]\u001b[38;5;241m.\u001b[39mgroupby([\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGEOID\u001b[39m\u001b[38;5;124m\"\u001b[39m])\u001b[38;5;241m.\u001b[39msum() \u001b[38;5;66;03m#.div(15) # 15 years\u001b[39;00m\n\u001b[1;32m      2\u001b[0m year_group \u001b[38;5;241m=\u001b[39m pdf[[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtime\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m+\u001b[39m hspts]\u001b[38;5;241m.\u001b[39mgroupby([\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtime\u001b[39m\u001b[38;5;124m\"\u001b[39m])\u001b[38;5;241m.\u001b[39msum()\n\u001b[1;32m      4\u001b[0m res[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mavg_exposure_person_days_per_year\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m get_mean_and_std(year_group, hspts)\n",
      "\u001b[0;31mNameError\u001b[0m: name 'pdf' is not defined"
     ]
    }
   ],
   "source": [
    "geoid_group = pdf[[\"GEOID\"]+ hspts].groupby([\"GEOID\"]).sum() #.div(15) # 15 years\n",
    "year_group = pdf[[\"time\"]+ hspts].groupby([\"time\"]).sum()\n",
    "\n",
    "res[\"avg_exposure_person_days_per_year\"] = get_mean_and_std(year_group, hspts)\n",
    "res[\"avg_exposure_person_days_per_ct\"] = get_mean_and_std(geoid_group, hspts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>wfday</th>\n",
       "      <th>heatday</th>\n",
       "      <th>smoke_pm_non_zero</th>\n",
       "      <th>smoke_pm_gt_five</th>\n",
       "      <th>hw</th>\n",
       "      <th>_hws</th>\n",
       "      <th>hs</th>\n",
       "      <th>hws</th>\n",
       "      <th>ws</th>\n",
       "      <th>hs5</th>\n",
       "      <th>...</th>\n",
       "      <th>wfday_2d</th>\n",
       "      <th>_hws_2d</th>\n",
       "      <th>hs_2d</th>\n",
       "      <th>hws_2d</th>\n",
       "      <th>ws_2d</th>\n",
       "      <th>hw_2d</th>\n",
       "      <th>smoke_pm_gt_five_2d</th>\n",
       "      <th>hs_2d_5</th>\n",
       "      <th>ws_2d_5</th>\n",
       "      <th>hws_2d_5</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GEOID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>04001942600</th>\n",
       "      <td>228.133333</td>\n",
       "      <td>11292.600000</td>\n",
       "      <td>46311.066667</td>\n",
       "      <td>7870.600000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>54752.000000</td>\n",
       "      <td>3079.800000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>798.466667</td>\n",
       "      <td>...</td>\n",
       "      <td>456.266667</td>\n",
       "      <td>81101.400000</td>\n",
       "      <td>6387.733333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11292.600000</td>\n",
       "      <td>1368.800000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>04001942700</th>\n",
       "      <td>3281.400000</td>\n",
       "      <td>50314.800000</td>\n",
       "      <td>159330.200000</td>\n",
       "      <td>24792.800000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>196154.800000</td>\n",
       "      <td>15313.200000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1458.400000</td>\n",
       "      <td>3646.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>6198.200000</td>\n",
       "      <td>288034.000000</td>\n",
       "      <td>30991.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3281.400000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>36095.400000</td>\n",
       "      <td>6927.400000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>04001944000</th>\n",
       "      <td>18854.066667</td>\n",
       "      <td>13154.000000</td>\n",
       "      <td>180209.800000</td>\n",
       "      <td>26746.466667</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>202571.600000</td>\n",
       "      <td>3069.266667</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>6577.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>31131.133333</td>\n",
       "      <td>307365.133333</td>\n",
       "      <td>6138.533333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>14030.933333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>40777.400000</td>\n",
       "      <td>876.933333</td>\n",
       "      <td>1315.400000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>04001944100</th>\n",
       "      <td>5358.600000</td>\n",
       "      <td>55647.000000</td>\n",
       "      <td>173536.200000</td>\n",
       "      <td>23907.600000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>214344.000000</td>\n",
       "      <td>16900.200000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3297.600000</td>\n",
       "      <td>4946.400000</td>\n",
       "      <td>...</td>\n",
       "      <td>9892.800000</td>\n",
       "      <td>314096.400000</td>\n",
       "      <td>32976.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7419.600000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>35861.400000</td>\n",
       "      <td>8244.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>04001944201</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>50848.000000</td>\n",
       "      <td>104722.666667</td>\n",
       "      <td>17252.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>141042.666667</td>\n",
       "      <td>14528.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3934.666667</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>208234.666667</td>\n",
       "      <td>28450.666667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>25424.000000</td>\n",
       "      <td>6961.333333</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56043000200</th>\n",
       "      <td>24158.933333</td>\n",
       "      <td>15828.266667</td>\n",
       "      <td>179734.133333</td>\n",
       "      <td>57898.133333</td>\n",
       "      <td>416.533333</td>\n",
       "      <td>202851.733333</td>\n",
       "      <td>9996.800000</td>\n",
       "      <td>208.266667</td>\n",
       "      <td>6664.533333</td>\n",
       "      <td>3540.533333</td>\n",
       "      <td>...</td>\n",
       "      <td>43736.000000</td>\n",
       "      <td>272829.333333</td>\n",
       "      <td>18535.733333</td>\n",
       "      <td>1249.6</td>\n",
       "      <td>16453.066667</td>\n",
       "      <td>1874.4</td>\n",
       "      <td>76850.400000</td>\n",
       "      <td>8538.933333</td>\n",
       "      <td>5206.666667</td>\n",
       "      <td>1041.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56043000301</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>15022.066667</td>\n",
       "      <td>89240.000000</td>\n",
       "      <td>42983.933333</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>96527.933333</td>\n",
       "      <td>7734.133333</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3420.866667</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>129844.200000</td>\n",
       "      <td>14724.600000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>57708.533333</td>\n",
       "      <td>7585.400000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56043000302</th>\n",
       "      <td>1203.066667</td>\n",
       "      <td>16842.933333</td>\n",
       "      <td>107588.533333</td>\n",
       "      <td>49497.600000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>116010.000000</td>\n",
       "      <td>9108.933333</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>515.600000</td>\n",
       "      <td>3781.066667</td>\n",
       "      <td>...</td>\n",
       "      <td>2406.133333</td>\n",
       "      <td>155023.733333</td>\n",
       "      <td>16842.933333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1203.066667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>66512.400000</td>\n",
       "      <td>8421.466667</td>\n",
       "      <td>515.600000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56045951100</th>\n",
       "      <td>7425.600000</td>\n",
       "      <td>21621.600000</td>\n",
       "      <td>187168.800000</td>\n",
       "      <td>39967.200000</td>\n",
       "      <td>1528.800000</td>\n",
       "      <td>199836.000000</td>\n",
       "      <td>12885.600000</td>\n",
       "      <td>1528.800000</td>\n",
       "      <td>3494.400000</td>\n",
       "      <td>3494.400000</td>\n",
       "      <td>...</td>\n",
       "      <td>12448.800000</td>\n",
       "      <td>265137.600000</td>\n",
       "      <td>25116.000000</td>\n",
       "      <td>2402.4</td>\n",
       "      <td>5241.600000</td>\n",
       "      <td>2402.4</td>\n",
       "      <td>55255.200000</td>\n",
       "      <td>7862.400000</td>\n",
       "      <td>2184.000000</td>\n",
       "      <td>1528.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56045951300</th>\n",
       "      <td>977.600000</td>\n",
       "      <td>20285.200000</td>\n",
       "      <td>165703.200000</td>\n",
       "      <td>50835.200000</td>\n",
       "      <td>733.200000</td>\n",
       "      <td>174990.400000</td>\n",
       "      <td>11242.400000</td>\n",
       "      <td>733.200000</td>\n",
       "      <td>733.200000</td>\n",
       "      <td>4154.800000</td>\n",
       "      <td>...</td>\n",
       "      <td>1466.400000</td>\n",
       "      <td>235846.000000</td>\n",
       "      <td>20285.200000</td>\n",
       "      <td>977.6</td>\n",
       "      <td>1222.000000</td>\n",
       "      <td>977.6</td>\n",
       "      <td>71120.400000</td>\n",
       "      <td>8554.000000</td>\n",
       "      <td>977.600000</td>\n",
       "      <td>977.600000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>18106 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    wfday       heatday  smoke_pm_non_zero  smoke_pm_gt_five  \\\n",
       "GEOID                                                                          \n",
       "04001942600    228.133333  11292.600000       46311.066667       7870.600000   \n",
       "04001942700   3281.400000  50314.800000      159330.200000      24792.800000   \n",
       "04001944000  18854.066667  13154.000000      180209.800000      26746.466667   \n",
       "04001944100   5358.600000  55647.000000      173536.200000      23907.600000   \n",
       "04001944201      0.000000  50848.000000      104722.666667      17252.000000   \n",
       "...                   ...           ...                ...               ...   \n",
       "56043000200  24158.933333  15828.266667      179734.133333      57898.133333   \n",
       "56043000301      0.000000  15022.066667       89240.000000      42983.933333   \n",
       "56043000302   1203.066667  16842.933333      107588.533333      49497.600000   \n",
       "56045951100   7425.600000  21621.600000      187168.800000      39967.200000   \n",
       "56045951300    977.600000  20285.200000      165703.200000      50835.200000   \n",
       "\n",
       "                      hw           _hws            hs          hws  \\\n",
       "GEOID                                                                \n",
       "04001942600     0.000000   54752.000000   3079.800000     0.000000   \n",
       "04001942700     0.000000  196154.800000  15313.200000     0.000000   \n",
       "04001944000     0.000000  202571.600000   3069.266667     0.000000   \n",
       "04001944100     0.000000  214344.000000  16900.200000     0.000000   \n",
       "04001944201     0.000000  141042.666667  14528.000000     0.000000   \n",
       "...                  ...            ...           ...          ...   \n",
       "56043000200   416.533333  202851.733333   9996.800000   208.266667   \n",
       "56043000301     0.000000   96527.933333   7734.133333     0.000000   \n",
       "56043000302     0.000000  116010.000000   9108.933333     0.000000   \n",
       "56045951100  1528.800000  199836.000000  12885.600000  1528.800000   \n",
       "56045951300   733.200000  174990.400000  11242.400000   733.200000   \n",
       "\n",
       "                      ws          hs5  ...      wfday_2d        _hws_2d  \\\n",
       "GEOID                                  ...                                \n",
       "04001942600     0.000000   798.466667  ...    456.266667   81101.400000   \n",
       "04001942700  1458.400000  3646.000000  ...   6198.200000  288034.000000   \n",
       "04001944000  6577.000000     0.000000  ...  31131.133333  307365.133333   \n",
       "04001944100  3297.600000  4946.400000  ...   9892.800000  314096.400000   \n",
       "04001944201     0.000000  3934.666667  ...      0.000000  208234.666667   \n",
       "...                  ...          ...  ...           ...            ...   \n",
       "56043000200  6664.533333  3540.533333  ...  43736.000000  272829.333333   \n",
       "56043000301     0.000000  3420.866667  ...      0.000000  129844.200000   \n",
       "56043000302   515.600000  3781.066667  ...   2406.133333  155023.733333   \n",
       "56045951100  3494.400000  3494.400000  ...  12448.800000  265137.600000   \n",
       "56045951300   733.200000  4154.800000  ...   1466.400000  235846.000000   \n",
       "\n",
       "                    hs_2d  hws_2d         ws_2d   hw_2d  smoke_pm_gt_five_2d  \\\n",
       "GEOID                                                                          \n",
       "04001942600   6387.733333     0.0      0.000000     0.0         11292.600000   \n",
       "04001942700  30991.000000     0.0   3281.400000     0.0         36095.400000   \n",
       "04001944000   6138.533333     0.0  14030.933333     0.0         40777.400000   \n",
       "04001944100  32976.000000     0.0   7419.600000     0.0         35861.400000   \n",
       "04001944201  28450.666667     0.0      0.000000     0.0         25424.000000   \n",
       "...                   ...     ...           ...     ...                  ...   \n",
       "56043000200  18535.733333  1249.6  16453.066667  1874.4         76850.400000   \n",
       "56043000301  14724.600000     0.0      0.000000     0.0         57708.533333   \n",
       "56043000302  16842.933333     0.0   1203.066667     0.0         66512.400000   \n",
       "56045951100  25116.000000  2402.4   5241.600000  2402.4         55255.200000   \n",
       "56045951300  20285.200000   977.6   1222.000000   977.6         71120.400000   \n",
       "\n",
       "                 hs_2d_5      ws_2d_5     hws_2d_5  \n",
       "GEOID                                               \n",
       "04001942600  1368.800000     0.000000     0.000000  \n",
       "04001942700  6927.400000     0.000000     0.000000  \n",
       "04001944000   876.933333  1315.400000     0.000000  \n",
       "04001944100  8244.000000     0.000000     0.000000  \n",
       "04001944201  6961.333333     0.000000     0.000000  \n",
       "...                  ...          ...          ...  \n",
       "56043000200  8538.933333  5206.666667  1041.333333  \n",
       "56043000301  7585.400000     0.000000     0.000000  \n",
       "56043000302  8421.466667   515.600000     0.000000  \n",
       "56045951100  7862.400000  2184.000000  1528.800000  \n",
       "56045951300  8554.000000   977.600000   977.600000  \n",
       "\n",
       "[18106 rows x 24 columns]"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geoid_group"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>avg_exposure_days_per_year</th>\n",
       "      <th>avg_exposure_days_per_ct</th>\n",
       "      <th>avg_exposure_person_days_per_year</th>\n",
       "      <th>avg_exposure_person_days_per_ct</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>wfday</th>\n",
       "      <td>7,709 (1,219)</td>\n",
       "      <td>0 (3)</td>\n",
       "      <td>25,236,989 (4,118,724)</td>\n",
       "      <td>1,394 (7,851)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>heatday</th>\n",
       "      <td>133,714 (47,400)</td>\n",
       "      <td>7 (3)</td>\n",
       "      <td>564,384,773 (201,498,211)</td>\n",
       "      <td>31,171 (19,861)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>smoke_pm_non_zero</th>\n",
       "      <td>481,564 (259,819)</td>\n",
       "      <td>27 (11)</td>\n",
       "      <td>1,976,217,709 (1,087,474,243)</td>\n",
       "      <td>109,147 (60,131)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>smoke_pm_gt_five</th>\n",
       "      <td>161,283 (167,991)</td>\n",
       "      <td>9 (5)</td>\n",
       "      <td>661,418,741 (700,910,652)</td>\n",
       "      <td>36,530 (24,946)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hw</th>\n",
       "      <td>209 (107)</td>\n",
       "      <td>0 (0)</td>\n",
       "      <td>699,180 (359,094)</td>\n",
       "      <td>39 (364)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>_hws</th>\n",
       "      <td>581,806 (268,376)</td>\n",
       "      <td>32 (10)</td>\n",
       "      <td>2,397,625,195 (1,122,359,277)</td>\n",
       "      <td>132,422 (65,985)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hs</th>\n",
       "      <td>38,214 (30,679)</td>\n",
       "      <td>2 (1)</td>\n",
       "      <td>159,109,815 (129,945,693)</td>\n",
       "      <td>8,788 (5,771)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hws</th>\n",
       "      <td>154 (99)</td>\n",
       "      <td>0 (0)</td>\n",
       "      <td>511,904 (330,385)</td>\n",
       "      <td>28 (290)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ws</th>\n",
       "      <td>2,913 (984)</td>\n",
       "      <td>0 (1)</td>\n",
       "      <td>8,917,186 (3,074,409)</td>\n",
       "      <td>492 (3,372)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hs5</th>\n",
       "      <td>14,662 (16,560)</td>\n",
       "      <td>1 (0)</td>\n",
       "      <td>60,861,691 (70,261,909)</td>\n",
       "      <td>3,361 (2,440)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hws5</th>\n",
       "      <td>88 (79)</td>\n",
       "      <td>0 (0)</td>\n",
       "      <td>286,757 (257,456)</td>\n",
       "      <td>16 (148)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ws5</th>\n",
       "      <td>1,285 (899)</td>\n",
       "      <td>0 (1)</td>\n",
       "      <td>3,819,262 (2,693,796)</td>\n",
       "      <td>211 (1,634)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>heatday_2d</th>\n",
       "      <td>197,868 (67,190)</td>\n",
       "      <td>11 (5)</td>\n",
       "      <td>835,253,698 (286,001,933)</td>\n",
       "      <td>46,131 (28,696)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>smoke_pm_non_zero_2d</th>\n",
       "      <td>690,931 (304,021)</td>\n",
       "      <td>38 (14)</td>\n",
       "      <td>2,841,718,868 (1,274,428,747)</td>\n",
       "      <td>156,949 (83,056)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>wfday_2d</th>\n",
       "      <td>13,134 (1,799)</td>\n",
       "      <td>1 (4)</td>\n",
       "      <td>43,814,401 (6,318,852)</td>\n",
       "      <td>2,420 (13,050)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>_hws_2d</th>\n",
       "      <td>822,251 (308,854)</td>\n",
       "      <td>45 (14)</td>\n",
       "      <td>3,393,875,027 (1,293,686,878)</td>\n",
       "      <td>187,445 (91,338)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hs_2d</th>\n",
       "      <td>73,931 (51,943)</td>\n",
       "      <td>4 (2)</td>\n",
       "      <td>308,554,705 (220,062,119)</td>\n",
       "      <td>17,042 (10,919)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hws_2d</th>\n",
       "      <td>365 (198)</td>\n",
       "      <td>0 (0)</td>\n",
       "      <td>1,247,793 (686,347)</td>\n",
       "      <td>69 (695)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ws_2d</th>\n",
       "      <td>5,649 (1,422)</td>\n",
       "      <td>0 (2)</td>\n",
       "      <td>18,006,301 (4,719,324)</td>\n",
       "      <td>994 (6,251)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hw_2d</th>\n",
       "      <td>468 (210)</td>\n",
       "      <td>0 (0)</td>\n",
       "      <td>1,598,726 (714,258)</td>\n",
       "      <td>88 (811)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>smoke_pm_gt_five_2d</th>\n",
       "      <td>221,407 (200,518)</td>\n",
       "      <td>12 (6)</td>\n",
       "      <td>909,884,776 (836,346,492)</td>\n",
       "      <td>50,253 (32,396)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hs_2d_5</th>\n",
       "      <td>28,495 (29,139)</td>\n",
       "      <td>2 (1)</td>\n",
       "      <td>118,328,725 (123,364,324)</td>\n",
       "      <td>6,535 (4,450)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>ws_2d_5</th>\n",
       "      <td>2,100 (1,281)</td>\n",
       "      <td>0 (1)</td>\n",
       "      <td>6,452,928 (3,972,325)</td>\n",
       "      <td>356 (2,354)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hws_2d_5</th>\n",
       "      <td>201 (156)</td>\n",
       "      <td>0 (0)</td>\n",
       "      <td>668,768 (529,089)</td>\n",
       "      <td>37 (321)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     avg_exposure_days_per_year avg_exposure_days_per_ct  \\\n",
       "wfday                             7,709 (1,219)                    0 (3)   \n",
       "heatday                        133,714 (47,400)                    7 (3)   \n",
       "smoke_pm_non_zero             481,564 (259,819)                  27 (11)   \n",
       "smoke_pm_gt_five              161,283 (167,991)                    9 (5)   \n",
       "hw                                    209 (107)                    0 (0)   \n",
       "_hws                          581,806 (268,376)                  32 (10)   \n",
       "hs                              38,214 (30,679)                    2 (1)   \n",
       "hws                                    154 (99)                    0 (0)   \n",
       "ws                                  2,913 (984)                    0 (1)   \n",
       "hs5                             14,662 (16,560)                    1 (0)   \n",
       "hws5                                    88 (79)                    0 (0)   \n",
       "ws5                                 1,285 (899)                    0 (1)   \n",
       "heatday_2d                     197,868 (67,190)                   11 (5)   \n",
       "smoke_pm_non_zero_2d          690,931 (304,021)                  38 (14)   \n",
       "wfday_2d                         13,134 (1,799)                    1 (4)   \n",
       "_hws_2d                       822,251 (308,854)                  45 (14)   \n",
       "hs_2d                           73,931 (51,943)                    4 (2)   \n",
       "hws_2d                                365 (198)                    0 (0)   \n",
       "ws_2d                             5,649 (1,422)                    0 (2)   \n",
       "hw_2d                                 468 (210)                    0 (0)   \n",
       "smoke_pm_gt_five_2d           221,407 (200,518)                   12 (6)   \n",
       "hs_2d_5                         28,495 (29,139)                    2 (1)   \n",
       "ws_2d_5                           2,100 (1,281)                    0 (1)   \n",
       "hws_2d_5                              201 (156)                    0 (0)   \n",
       "\n",
       "                     avg_exposure_person_days_per_year  \\\n",
       "wfday                           25,236,989 (4,118,724)   \n",
       "heatday                      564,384,773 (201,498,211)   \n",
       "smoke_pm_non_zero        1,976,217,709 (1,087,474,243)   \n",
       "smoke_pm_gt_five             661,418,741 (700,910,652)   \n",
       "hw                                   699,180 (359,094)   \n",
       "_hws                     2,397,625,195 (1,122,359,277)   \n",
       "hs                           159,109,815 (129,945,693)   \n",
       "hws                                  511,904 (330,385)   \n",
       "ws                               8,917,186 (3,074,409)   \n",
       "hs5                            60,861,691 (70,261,909)   \n",
       "hws5                                 286,757 (257,456)   \n",
       "ws5                              3,819,262 (2,693,796)   \n",
       "heatday_2d                   835,253,698 (286,001,933)   \n",
       "smoke_pm_non_zero_2d     2,841,718,868 (1,274,428,747)   \n",
       "wfday_2d                        43,814,401 (6,318,852)   \n",
       "_hws_2d                  3,393,875,027 (1,293,686,878)   \n",
       "hs_2d                        308,554,705 (220,062,119)   \n",
       "hws_2d                             1,247,793 (686,347)   \n",
       "ws_2d                           18,006,301 (4,719,324)   \n",
       "hw_2d                              1,598,726 (714,258)   \n",
       "smoke_pm_gt_five_2d          909,884,776 (836,346,492)   \n",
       "hs_2d_5                      118,328,725 (123,364,324)   \n",
       "ws_2d_5                          6,452,928 (3,972,325)   \n",
       "hws_2d_5                             668,768 (529,089)   \n",
       "\n",
       "                     avg_exposure_person_days_per_ct  \n",
       "wfday                                  1,394 (7,851)  \n",
       "heatday                              31,171 (19,861)  \n",
       "smoke_pm_non_zero                   109,147 (60,131)  \n",
       "smoke_pm_gt_five                     36,530 (24,946)  \n",
       "hw                                          39 (364)  \n",
       "_hws                                132,422 (65,985)  \n",
       "hs                                     8,788 (5,771)  \n",
       "hws                                         28 (290)  \n",
       "ws                                       492 (3,372)  \n",
       "hs5                                    3,361 (2,440)  \n",
       "hws5                                        16 (148)  \n",
       "ws5                                      211 (1,634)  \n",
       "heatday_2d                           46,131 (28,696)  \n",
       "smoke_pm_non_zero_2d                156,949 (83,056)  \n",
       "wfday_2d                              2,420 (13,050)  \n",
       "_hws_2d                             187,445 (91,338)  \n",
       "hs_2d                                17,042 (10,919)  \n",
       "hws_2d                                      69 (695)  \n",
       "ws_2d                                    994 (6,251)  \n",
       "hw_2d                                       88 (811)  \n",
       "smoke_pm_gt_five_2d                  50,253 (32,396)  \n",
       "hs_2d_5                                6,535 (4,450)  \n",
       "ws_2d_5                                  356 (2,354)  \n",
       "hws_2d_5                                    37 (321)  "
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# California stats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FIPS</th>\n",
       "      <th>ST_ABBR</th>\n",
       "      <th>E_TOTPOP</th>\n",
       "      <th>GEOID</th>\n",
       "      <th>time</th>\n",
       "      <th>wfday</th>\n",
       "      <th>heatday</th>\n",
       "      <th>smoke_pm_non_zero</th>\n",
       "      <th>smoke_pm_gt_five</th>\n",
       "      <th>hw</th>\n",
       "      <th>...</th>\n",
       "      <th>wfday_2d</th>\n",
       "      <th>_hws_2d</th>\n",
       "      <th>hs_2d</th>\n",
       "      <th>hws_2d</th>\n",
       "      <th>ws_2d</th>\n",
       "      <th>hw_2d</th>\n",
       "      <th>smoke_pm_gt_five_2d</th>\n",
       "      <th>hs_2d_5</th>\n",
       "      <th>ws_2d_5</th>\n",
       "      <th>hws_2d_5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2006-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>13688</td>\n",
       "      <td>49619</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>92394</td>\n",
       "      <td>6844</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5133</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2007-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>18821</td>\n",
       "      <td>32509</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>73573</td>\n",
       "      <td>5133</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5133</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2008-12-31</td>\n",
       "      <td>1711</td>\n",
       "      <td>3422</td>\n",
       "      <td>41064</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>3422</td>\n",
       "      <td>73573</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2009-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>6844</td>\n",
       "      <td>37642</td>\n",
       "      <td>5133</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>63307</td>\n",
       "      <td>3422</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8555</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>04001942600</td>\n",
       "      <td>AZ</td>\n",
       "      <td>1711</td>\n",
       "      <td>04001942600</td>\n",
       "      <td>2010-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>10266</td>\n",
       "      <td>30798</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>59885</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 29 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          FIPS ST_ABBR  E_TOTPOP        GEOID       time  wfday  heatday  \\\n",
       "0  04001942600      AZ      1711  04001942600 2006-12-31      0    13688   \n",
       "1  04001942600      AZ      1711  04001942600 2007-12-31      0    18821   \n",
       "2  04001942600      AZ      1711  04001942600 2008-12-31   1711     3422   \n",
       "3  04001942600      AZ      1711  04001942600 2009-12-31      0     6844   \n",
       "4  04001942600      AZ      1711  04001942600 2010-12-31      0    10266   \n",
       "\n",
       "   smoke_pm_non_zero  smoke_pm_gt_five  hw  ...  wfday_2d  _hws_2d  hs_2d  \\\n",
       "0              49619              3422   0  ...         0    92394   6844   \n",
       "1              32509              3422   0  ...         0    73573   5133   \n",
       "2              41064                 0   0  ...      3422    73573   3422   \n",
       "3              37642              5133   0  ...         0    63307   3422   \n",
       "4              30798                 0   0  ...         0    59885      0   \n",
       "\n",
       "   hws_2d  ws_2d  hw_2d  smoke_pm_gt_five_2d  hs_2d_5  ws_2d_5  hws_2d_5  \n",
       "0       0      0      0                 5133        0        0         0  \n",
       "1       0      0      0                 5133     3422        0         0  \n",
       "2       0      0      0                    0        0        0         0  \n",
       "3       0      0      0                 8555        0        0         0  \n",
       "4       0      0      0                    0        0        0         0  \n",
       "\n",
       "[5 rows x 29 columns]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pdf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FIPS</th>\n",
       "      <th>ST_ABBR</th>\n",
       "      <th>E_TOTPOP</th>\n",
       "      <th>GEOID</th>\n",
       "      <th>time</th>\n",
       "      <th>wfday</th>\n",
       "      <th>heatday</th>\n",
       "      <th>smoke_pm_non_zero</th>\n",
       "      <th>smoke_pm_gt_five</th>\n",
       "      <th>hw</th>\n",
       "      <th>...</th>\n",
       "      <th>wfday_2d</th>\n",
       "      <th>_hws_2d</th>\n",
       "      <th>hs_2d</th>\n",
       "      <th>hws_2d</th>\n",
       "      <th>ws_2d</th>\n",
       "      <th>hw_2d</th>\n",
       "      <th>smoke_pm_gt_five_2d</th>\n",
       "      <th>hs_2d_5</th>\n",
       "      <th>ws_2d_5</th>\n",
       "      <th>hws_2d_5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>26475</th>\n",
       "      <td>06001400100</td>\n",
       "      <td>CA</td>\n",
       "      <td>3035</td>\n",
       "      <td>06001400100</td>\n",
       "      <td>2006-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>15175</td>\n",
       "      <td>60700</td>\n",
       "      <td>6070</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>124435</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9105</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26476</th>\n",
       "      <td>06001400100</td>\n",
       "      <td>CA</td>\n",
       "      <td>3035</td>\n",
       "      <td>06001400100</td>\n",
       "      <td>2007-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>6070</td>\n",
       "      <td>39455</td>\n",
       "      <td>9105</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>60700</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>15175</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26477</th>\n",
       "      <td>06001400100</td>\n",
       "      <td>CA</td>\n",
       "      <td>3035</td>\n",
       "      <td>06001400100</td>\n",
       "      <td>2008-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>24280</td>\n",
       "      <td>142645</td>\n",
       "      <td>69805</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>221555</td>\n",
       "      <td>9105</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>94085</td>\n",
       "      <td>9105</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26478</th>\n",
       "      <td>06001400100</td>\n",
       "      <td>CA</td>\n",
       "      <td>3035</td>\n",
       "      <td>06001400100</td>\n",
       "      <td>2009-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>15175</td>\n",
       "      <td>36420</td>\n",
       "      <td>12140</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>75875</td>\n",
       "      <td>6070</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>18210</td>\n",
       "      <td>3035</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26479</th>\n",
       "      <td>06001400100</td>\n",
       "      <td>CA</td>\n",
       "      <td>3035</td>\n",
       "      <td>06001400100</td>\n",
       "      <td>2010-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>27315</td>\n",
       "      <td>33385</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>81945</td>\n",
       "      <td>6070</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162895</th>\n",
       "      <td>06115041102</td>\n",
       "      <td>CA</td>\n",
       "      <td>1027</td>\n",
       "      <td>06115041102</td>\n",
       "      <td>2016-12-31</td>\n",
       "      <td>0</td>\n",
       "      <td>5135</td>\n",
       "      <td>49296</td>\n",
       "      <td>10270</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>64701</td>\n",
       "      <td>6162</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>14378</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162896</th>\n",
       "      <td>06115041102</td>\n",
       "      <td>CA</td>\n",
       "      <td>1027</td>\n",
       "      <td>06115041102</td>\n",
       "      <td>2017-12-31</td>\n",
       "      <td>1027</td>\n",
       "      <td>17459</td>\n",
       "      <td>70863</td>\n",
       "      <td>33891</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2054</td>\n",
       "      <td>96538</td>\n",
       "      <td>15405</td>\n",
       "      <td>0</td>\n",
       "      <td>1027</td>\n",
       "      <td>0</td>\n",
       "      <td>43134</td>\n",
       "      <td>9243</td>\n",
       "      <td>1027</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162897</th>\n",
       "      <td>06115041102</td>\n",
       "      <td>CA</td>\n",
       "      <td>1027</td>\n",
       "      <td>06115041102</td>\n",
       "      <td>2018-12-31</td>\n",
       "      <td>1027</td>\n",
       "      <td>5135</td>\n",
       "      <td>87295</td>\n",
       "      <td>55458</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2054</td>\n",
       "      <td>115024</td>\n",
       "      <td>5135</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>65728</td>\n",
       "      <td>1027</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162898</th>\n",
       "      <td>06115041102</td>\n",
       "      <td>CA</td>\n",
       "      <td>1027</td>\n",
       "      <td>06115041102</td>\n",
       "      <td>2019-12-31</td>\n",
       "      <td>1027</td>\n",
       "      <td>1027</td>\n",
       "      <td>40053</td>\n",
       "      <td>4108</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2054</td>\n",
       "      <td>68809</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1027</td>\n",
       "      <td>0</td>\n",
       "      <td>6162</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162899</th>\n",
       "      <td>06115041102</td>\n",
       "      <td>CA</td>\n",
       "      <td>1027</td>\n",
       "      <td>06115041102</td>\n",
       "      <td>2020-12-31</td>\n",
       "      <td>1027</td>\n",
       "      <td>9243</td>\n",
       "      <td>103727</td>\n",
       "      <td>62647</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>2054</td>\n",
       "      <td>133510</td>\n",
       "      <td>7189</td>\n",
       "      <td>0</td>\n",
       "      <td>2054</td>\n",
       "      <td>0</td>\n",
       "      <td>68809</td>\n",
       "      <td>6162</td>\n",
       "      <td>2054</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>136425 rows × 29 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               FIPS ST_ABBR  E_TOTPOP        GEOID       time  wfday  heatday  \\\n",
       "26475   06001400100      CA      3035  06001400100 2006-12-31      0    15175   \n",
       "26476   06001400100      CA      3035  06001400100 2007-12-31      0     6070   \n",
       "26477   06001400100      CA      3035  06001400100 2008-12-31      0    24280   \n",
       "26478   06001400100      CA      3035  06001400100 2009-12-31      0    15175   \n",
       "26479   06001400100      CA      3035  06001400100 2010-12-31      0    27315   \n",
       "...             ...     ...       ...          ...        ...    ...      ...   \n",
       "162895  06115041102      CA      1027  06115041102 2016-12-31      0     5135   \n",
       "162896  06115041102      CA      1027  06115041102 2017-12-31   1027    17459   \n",
       "162897  06115041102      CA      1027  06115041102 2018-12-31   1027     5135   \n",
       "162898  06115041102      CA      1027  06115041102 2019-12-31   1027     1027   \n",
       "162899  06115041102      CA      1027  06115041102 2020-12-31   1027     9243   \n",
       "\n",
       "        smoke_pm_non_zero  smoke_pm_gt_five  hw  ...  wfday_2d  _hws_2d  \\\n",
       "26475               60700              6070   0  ...         0   124435   \n",
       "26476               39455              9105   0  ...         0    60700   \n",
       "26477              142645             69805   0  ...         0   221555   \n",
       "26478               36420             12140   0  ...         0    75875   \n",
       "26479               33385                 0   0  ...         0    81945   \n",
       "...                   ...               ...  ..  ...       ...      ...   \n",
       "162895              49296             10270   0  ...         0    64701   \n",
       "162896              70863             33891   0  ...      2054    96538   \n",
       "162897              87295             55458   0  ...      2054   115024   \n",
       "162898              40053              4108   0  ...      2054    68809   \n",
       "162899             103727             62647   0  ...      2054   133510   \n",
       "\n",
       "        hs_2d  hws_2d  ws_2d  hw_2d  smoke_pm_gt_five_2d  hs_2d_5  ws_2d_5  \\\n",
       "26475       0       0      0      0                 9105        0        0   \n",
       "26476       0       0      0      0                15175        0        0   \n",
       "26477    9105       0      0      0                94085     9105        0   \n",
       "26478    6070       0      0      0                18210     3035        0   \n",
       "26479    6070       0      0      0                    0        0        0   \n",
       "...       ...     ...    ...    ...                  ...      ...      ...   \n",
       "162895   6162       0      0      0                14378        0        0   \n",
       "162896  15405       0   1027      0                43134     9243     1027   \n",
       "162897   5135       0      0      0                65728     1027        0   \n",
       "162898      0       0   1027      0                 6162        0        0   \n",
       "162899   7189       0   2054      0                68809     6162     2054   \n",
       "\n",
       "        hws_2d_5  \n",
       "26475          0  \n",
       "26476          0  \n",
       "26477          0  \n",
       "26478          0  \n",
       "26479          0  \n",
       "...          ...  \n",
       "162895         0  \n",
       "162896         0  \n",
       "162897         0  \n",
       "162898         0  \n",
       "162899         0  \n",
       "\n",
       "[136425 rows x 29 columns]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "temp = pdf[pdf[\"ST_ABBR\"] == \"CA\"]\n",
    "temp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>wfday</th>\n",
       "      <th>heatday</th>\n",
       "      <th>smoke_pm_non_zero</th>\n",
       "      <th>smoke_pm_gt_five</th>\n",
       "      <th>hw</th>\n",
       "      <th>_hws</th>\n",
       "      <th>hs</th>\n",
       "      <th>hws</th>\n",
       "      <th>ws</th>\n",
       "      <th>hs5</th>\n",
       "      <th>...</th>\n",
       "      <th>wfday_2d</th>\n",
       "      <th>_hws_2d</th>\n",
       "      <th>hs_2d</th>\n",
       "      <th>hws_2d</th>\n",
       "      <th>ws_2d</th>\n",
       "      <th>hw_2d</th>\n",
       "      <th>smoke_pm_gt_five_2d</th>\n",
       "      <th>hs_2d_5</th>\n",
       "      <th>ws_2d_5</th>\n",
       "      <th>hws_2d_5</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2006-12-31</th>\n",
       "      <td>8895908</td>\n",
       "      <td>249808124</td>\n",
       "      <td>697738378</td>\n",
       "      <td>189821532</td>\n",
       "      <td>256147</td>\n",
       "      <td>942320709</td>\n",
       "      <td>11478341</td>\n",
       "      <td>98604</td>\n",
       "      <td>2485817</td>\n",
       "      <td>1336383</td>\n",
       "      <td>...</td>\n",
       "      <td>15904410</td>\n",
       "      <td>1489053282</td>\n",
       "      <td>37675788</td>\n",
       "      <td>256273</td>\n",
       "      <td>5020910</td>\n",
       "      <td>507369</td>\n",
       "      <td>324105331</td>\n",
       "      <td>3713729</td>\n",
       "      <td>1879389</td>\n",
       "      <td>65268</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007-12-31</th>\n",
       "      <td>9354580</td>\n",
       "      <td>130086132</td>\n",
       "      <td>820364123</td>\n",
       "      <td>307360764</td>\n",
       "      <td>43593</td>\n",
       "      <td>946511006</td>\n",
       "      <td>11028545</td>\n",
       "      <td>20896</td>\n",
       "      <td>2242587</td>\n",
       "      <td>9853666</td>\n",
       "      <td>...</td>\n",
       "      <td>17136208</td>\n",
       "      <td>1452209669</td>\n",
       "      <td>27720579</td>\n",
       "      <td>93973</td>\n",
       "      <td>4964052</td>\n",
       "      <td>153429</td>\n",
       "      <td>434860974</td>\n",
       "      <td>18487369</td>\n",
       "      <td>1858900</td>\n",
       "      <td>55686</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008-12-31</th>\n",
       "      <td>12043600</td>\n",
       "      <td>186240708</td>\n",
       "      <td>1366388442</td>\n",
       "      <td>688298772</td>\n",
       "      <td>232590</td>\n",
       "      <td>1496498304</td>\n",
       "      <td>63288138</td>\n",
       "      <td>195489</td>\n",
       "      <td>4849207</td>\n",
       "      <td>46091472</td>\n",
       "      <td>...</td>\n",
       "      <td>20164697</td>\n",
       "      <td>2099679053</td>\n",
       "      <td>104906585</td>\n",
       "      <td>391033</td>\n",
       "      <td>8268243</td>\n",
       "      <td>462595</td>\n",
       "      <td>918020144</td>\n",
       "      <td>66453508</td>\n",
       "      <td>4672674</td>\n",
       "      <td>342521</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009-12-31</th>\n",
       "      <td>8309643</td>\n",
       "      <td>206231435</td>\n",
       "      <td>724555962</td>\n",
       "      <td>232381115</td>\n",
       "      <td>117576</td>\n",
       "      <td>882394409</td>\n",
       "      <td>54808420</td>\n",
       "      <td>78505</td>\n",
       "      <td>1855140</td>\n",
       "      <td>20522960</td>\n",
       "      <td>...</td>\n",
       "      <td>15216822</td>\n",
       "      <td>1336889257</td>\n",
       "      <td>111724946</td>\n",
       "      <td>208141</td>\n",
       "      <td>4467515</td>\n",
       "      <td>303247</td>\n",
       "      <td>360400162</td>\n",
       "      <td>47309239</td>\n",
       "      <td>1253410</td>\n",
       "      <td>122741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-12-31</th>\n",
       "      <td>5242252</td>\n",
       "      <td>314832700</td>\n",
       "      <td>290929169</td>\n",
       "      <td>15546588</td>\n",
       "      <td>64484</td>\n",
       "      <td>582244852</td>\n",
       "      <td>27764106</td>\n",
       "      <td>28487</td>\n",
       "      <td>959166</td>\n",
       "      <td>1386591</td>\n",
       "      <td>...</td>\n",
       "      <td>9851106</td>\n",
       "      <td>894625506</td>\n",
       "      <td>70471996</td>\n",
       "      <td>120871</td>\n",
       "      <td>2795148</td>\n",
       "      <td>200990</td>\n",
       "      <td>28820435</td>\n",
       "      <td>3512535</td>\n",
       "      <td>317703</td>\n",
       "      <td>1705</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011-12-31</th>\n",
       "      <td>5951088</td>\n",
       "      <td>106672303</td>\n",
       "      <td>263205620</td>\n",
       "      <td>31754770</td>\n",
       "      <td>31626</td>\n",
       "      <td>363161694</td>\n",
       "      <td>11401306</td>\n",
       "      <td>8577</td>\n",
       "      <td>1242962</td>\n",
       "      <td>212002</td>\n",
       "      <td>...</td>\n",
       "      <td>11189496</td>\n",
       "      <td>631071156</td>\n",
       "      <td>20638771</td>\n",
       "      <td>40798</td>\n",
       "      <td>3888296</td>\n",
       "      <td>80917</td>\n",
       "      <td>60437915</td>\n",
       "      <td>761487</td>\n",
       "      <td>468081</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-12-31</th>\n",
       "      <td>6099927</td>\n",
       "      <td>285661229</td>\n",
       "      <td>405540729</td>\n",
       "      <td>70847786</td>\n",
       "      <td>273668</td>\n",
       "      <td>671012040</td>\n",
       "      <td>24592657</td>\n",
       "      <td>233933</td>\n",
       "      <td>1657453</td>\n",
       "      <td>7742206</td>\n",
       "      <td>...</td>\n",
       "      <td>10990999</td>\n",
       "      <td>1070055780</td>\n",
       "      <td>55657880</td>\n",
       "      <td>380613</td>\n",
       "      <td>3634352</td>\n",
       "      <td>473052</td>\n",
       "      <td>121083082</td>\n",
       "      <td>14791069</td>\n",
       "      <td>1130793</td>\n",
       "      <td>280803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-12-31</th>\n",
       "      <td>7453213</td>\n",
       "      <td>191555336</td>\n",
       "      <td>1019928340</td>\n",
       "      <td>180202329</td>\n",
       "      <td>87735</td>\n",
       "      <td>1138705291</td>\n",
       "      <td>78175247</td>\n",
       "      <td>72040</td>\n",
       "      <td>2040656</td>\n",
       "      <td>14573965</td>\n",
       "      <td>...</td>\n",
       "      <td>13614931</td>\n",
       "      <td>1689670706</td>\n",
       "      <td>135065361</td>\n",
       "      <td>163280</td>\n",
       "      <td>4839577</td>\n",
       "      <td>218711</td>\n",
       "      <td>295090513</td>\n",
       "      <td>27688206</td>\n",
       "      <td>1346193</td>\n",
       "      <td>87169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-12-31</th>\n",
       "      <td>6057460</td>\n",
       "      <td>422779162</td>\n",
       "      <td>500207674</td>\n",
       "      <td>123302357</td>\n",
       "      <td>278973</td>\n",
       "      <td>881638154</td>\n",
       "      <td>45782461</td>\n",
       "      <td>184698</td>\n",
       "      <td>1529406</td>\n",
       "      <td>19554990</td>\n",
       "      <td>...</td>\n",
       "      <td>11068775</td>\n",
       "      <td>1353798605</td>\n",
       "      <td>93252931</td>\n",
       "      <td>477678</td>\n",
       "      <td>3610384</td>\n",
       "      <td>587932</td>\n",
       "      <td>205276274</td>\n",
       "      <td>38157253</td>\n",
       "      <td>1449957</td>\n",
       "      <td>267414</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-12-31</th>\n",
       "      <td>7838389</td>\n",
       "      <td>464458253</td>\n",
       "      <td>762143615</td>\n",
       "      <td>103949806</td>\n",
       "      <td>183897</td>\n",
       "      <td>1184627965</td>\n",
       "      <td>47546942</td>\n",
       "      <td>148935</td>\n",
       "      <td>2230388</td>\n",
       "      <td>15576626</td>\n",
       "      <td>...</td>\n",
       "      <td>13959228</td>\n",
       "      <td>1753226052</td>\n",
       "      <td>115979307</td>\n",
       "      <td>424562</td>\n",
       "      <td>4597443</td>\n",
       "      <td>503437</td>\n",
       "      <td>162930895</td>\n",
       "      <td>29921011</td>\n",
       "      <td>1574691</td>\n",
       "      <td>91998</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-12-31</th>\n",
       "      <td>7744379</td>\n",
       "      <td>343560661</td>\n",
       "      <td>1395513199</td>\n",
       "      <td>181755063</td>\n",
       "      <td>121846</td>\n",
       "      <td>1659958846</td>\n",
       "      <td>84851635</td>\n",
       "      <td>58014</td>\n",
       "      <td>1943926</td>\n",
       "      <td>21378771</td>\n",
       "      <td>...</td>\n",
       "      <td>14135512</td>\n",
       "      <td>2261802183</td>\n",
       "      <td>205419085</td>\n",
       "      <td>183556</td>\n",
       "      <td>4396263</td>\n",
       "      <td>344081</td>\n",
       "      <td>295234465</td>\n",
       "      <td>58856460</td>\n",
       "      <td>1196653</td>\n",
       "      <td>85233</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31</th>\n",
       "      <td>11216662</td>\n",
       "      <td>544122987</td>\n",
       "      <td>1546445746</td>\n",
       "      <td>533418780</td>\n",
       "      <td>405205</td>\n",
       "      <td>1869482221</td>\n",
       "      <td>228007060</td>\n",
       "      <td>304106</td>\n",
       "      <td>4195015</td>\n",
       "      <td>79912429</td>\n",
       "      <td>...</td>\n",
       "      <td>19780790</td>\n",
       "      <td>2600254117</td>\n",
       "      <td>393948499</td>\n",
       "      <td>776180</td>\n",
       "      <td>8444762</td>\n",
       "      <td>915322</td>\n",
       "      <td>794778029</td>\n",
       "      <td>149559784</td>\n",
       "      <td>4153219</td>\n",
       "      <td>525370</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-31</th>\n",
       "      <td>11064821</td>\n",
       "      <td>237332954</td>\n",
       "      <td>1647726613</td>\n",
       "      <td>690219146</td>\n",
       "      <td>220990</td>\n",
       "      <td>1788647824</td>\n",
       "      <td>103253442</td>\n",
       "      <td>176631</td>\n",
       "      <td>4178763</td>\n",
       "      <td>12000029</td>\n",
       "      <td>...</td>\n",
       "      <td>19317977</td>\n",
       "      <td>2409623759</td>\n",
       "      <td>204652450</td>\n",
       "      <td>457172</td>\n",
       "      <td>8629677</td>\n",
       "      <td>541385</td>\n",
       "      <td>898403041</td>\n",
       "      <td>36049220</td>\n",
       "      <td>3732975</td>\n",
       "      <td>177674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-12-31</th>\n",
       "      <td>8538419</td>\n",
       "      <td>251900215</td>\n",
       "      <td>600916745</td>\n",
       "      <td>86370304</td>\n",
       "      <td>48776</td>\n",
       "      <td>843016750</td>\n",
       "      <td>16153366</td>\n",
       "      <td>0</td>\n",
       "      <td>2136487</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>15949882</td>\n",
       "      <td>1405222877</td>\n",
       "      <td>37528337</td>\n",
       "      <td>60828</td>\n",
       "      <td>5927942</td>\n",
       "      <td>195005</td>\n",
       "      <td>145928847</td>\n",
       "      <td>549665</td>\n",
       "      <td>1098197</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-31</th>\n",
       "      <td>14312063</td>\n",
       "      <td>529012889</td>\n",
       "      <td>2862135655</td>\n",
       "      <td>1746730171</td>\n",
       "      <td>530148</td>\n",
       "      <td>3118640370</td>\n",
       "      <td>279940365</td>\n",
       "      <td>483134</td>\n",
       "      <td>6832858</td>\n",
       "      <td>179937190</td>\n",
       "      <td>...</td>\n",
       "      <td>23634510</td>\n",
       "      <td>3791059512</td>\n",
       "      <td>472410089</td>\n",
       "      <td>1006671</td>\n",
       "      <td>11819268</td>\n",
       "      <td>1074753</td>\n",
       "      <td>2058376106</td>\n",
       "      <td>315959484</td>\n",
       "      <td>7166513</td>\n",
       "      <td>739833</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>15 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               wfday    heatday  smoke_pm_non_zero  smoke_pm_gt_five      hw  \\\n",
       "time                                                                           \n",
       "2006-12-31   8895908  249808124          697738378         189821532  256147   \n",
       "2007-12-31   9354580  130086132          820364123         307360764   43593   \n",
       "2008-12-31  12043600  186240708         1366388442         688298772  232590   \n",
       "2009-12-31   8309643  206231435          724555962         232381115  117576   \n",
       "2010-12-31   5242252  314832700          290929169          15546588   64484   \n",
       "2011-12-31   5951088  106672303          263205620          31754770   31626   \n",
       "2012-12-31   6099927  285661229          405540729          70847786  273668   \n",
       "2013-12-31   7453213  191555336         1019928340         180202329   87735   \n",
       "2014-12-31   6057460  422779162          500207674         123302357  278973   \n",
       "2015-12-31   7838389  464458253          762143615         103949806  183897   \n",
       "2016-12-31   7744379  343560661         1395513199         181755063  121846   \n",
       "2017-12-31  11216662  544122987         1546445746         533418780  405205   \n",
       "2018-12-31  11064821  237332954         1647726613         690219146  220990   \n",
       "2019-12-31   8538419  251900215          600916745          86370304   48776   \n",
       "2020-12-31  14312063  529012889         2862135655        1746730171  530148   \n",
       "\n",
       "                  _hws         hs     hws       ws        hs5  ...  wfday_2d  \\\n",
       "time                                                           ...             \n",
       "2006-12-31   942320709   11478341   98604  2485817    1336383  ...  15904410   \n",
       "2007-12-31   946511006   11028545   20896  2242587    9853666  ...  17136208   \n",
       "2008-12-31  1496498304   63288138  195489  4849207   46091472  ...  20164697   \n",
       "2009-12-31   882394409   54808420   78505  1855140   20522960  ...  15216822   \n",
       "2010-12-31   582244852   27764106   28487   959166    1386591  ...   9851106   \n",
       "2011-12-31   363161694   11401306    8577  1242962     212002  ...  11189496   \n",
       "2012-12-31   671012040   24592657  233933  1657453    7742206  ...  10990999   \n",
       "2013-12-31  1138705291   78175247   72040  2040656   14573965  ...  13614931   \n",
       "2014-12-31   881638154   45782461  184698  1529406   19554990  ...  11068775   \n",
       "2015-12-31  1184627965   47546942  148935  2230388   15576626  ...  13959228   \n",
       "2016-12-31  1659958846   84851635   58014  1943926   21378771  ...  14135512   \n",
       "2017-12-31  1869482221  228007060  304106  4195015   79912429  ...  19780790   \n",
       "2018-12-31  1788647824  103253442  176631  4178763   12000029  ...  19317977   \n",
       "2019-12-31   843016750   16153366       0  2136487          0  ...  15949882   \n",
       "2020-12-31  3118640370  279940365  483134  6832858  179937190  ...  23634510   \n",
       "\n",
       "               _hws_2d      hs_2d   hws_2d     ws_2d    hw_2d  \\\n",
       "time                                                            \n",
       "2006-12-31  1489053282   37675788   256273   5020910   507369   \n",
       "2007-12-31  1452209669   27720579    93973   4964052   153429   \n",
       "2008-12-31  2099679053  104906585   391033   8268243   462595   \n",
       "2009-12-31  1336889257  111724946   208141   4467515   303247   \n",
       "2010-12-31   894625506   70471996   120871   2795148   200990   \n",
       "2011-12-31   631071156   20638771    40798   3888296    80917   \n",
       "2012-12-31  1070055780   55657880   380613   3634352   473052   \n",
       "2013-12-31  1689670706  135065361   163280   4839577   218711   \n",
       "2014-12-31  1353798605   93252931   477678   3610384   587932   \n",
       "2015-12-31  1753226052  115979307   424562   4597443   503437   \n",
       "2016-12-31  2261802183  205419085   183556   4396263   344081   \n",
       "2017-12-31  2600254117  393948499   776180   8444762   915322   \n",
       "2018-12-31  2409623759  204652450   457172   8629677   541385   \n",
       "2019-12-31  1405222877   37528337    60828   5927942   195005   \n",
       "2020-12-31  3791059512  472410089  1006671  11819268  1074753   \n",
       "\n",
       "            smoke_pm_gt_five_2d    hs_2d_5  ws_2d_5  hws_2d_5  \n",
       "time                                                           \n",
       "2006-12-31            324105331    3713729  1879389     65268  \n",
       "2007-12-31            434860974   18487369  1858900     55686  \n",
       "2008-12-31            918020144   66453508  4672674    342521  \n",
       "2009-12-31            360400162   47309239  1253410    122741  \n",
       "2010-12-31             28820435    3512535   317703      1705  \n",
       "2011-12-31             60437915     761487   468081         0  \n",
       "2012-12-31            121083082   14791069  1130793    280803  \n",
       "2013-12-31            295090513   27688206  1346193     87169  \n",
       "2014-12-31            205276274   38157253  1449957    267414  \n",
       "2015-12-31            162930895   29921011  1574691     91998  \n",
       "2016-12-31            295234465   58856460  1196653     85233  \n",
       "2017-12-31            794778029  149559784  4153219    525370  \n",
       "2018-12-31            898403041   36049220  3732975    177674  \n",
       "2019-12-31            145928847     549665  1098197         0  \n",
       "2020-12-31           2058376106  315959484  7166513    739833  \n",
       "\n",
       "[15 rows x 24 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "year_group = temp[[\"time\"]+ hspts].groupby([\"time\"]).sum()\n",
    "year_group"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "72538135.4"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "year_group[\"hs\"].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Just 2020 for CA\n",
    "\n",
    "279,940,365"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
